#define _CRT_SECURE_NO_WARNINGS




#include <iostream>
#include<unordered_set>
using namespace std;
const int N = 25;
int a[N];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }

    int ret = 0x3f3f3f3f;
    unordered_set<int> st;
    for (int i = 1; i <= n; ++i)
    {
        unordered_set<int> tmp;
        tmp.insert(a[i]);
        for (int x : st)
        {
            tmp.insert(x & a[i]);
        }
        st = tmp;
        if (!st.empty())
        {
            int sum = *min_element(st.begin(), st.end());
            ret = min(ret, sum);
        }
    }

    cout << ret;

    return 0;
}
